package com.voxel.sense.infomsg.module.task.check;

import android.view.View;

import com.example.com.common.view.recycler.RecyclerAdapter;
import com.voxel.sense.infomsg.R;
import com.voxel.sense.infomsg.data.bean.MultiItemBean;
import com.voxel.sense.infomsg.module.task.check.holder.DescHolderView;
import com.voxel.sense.infomsg.module.task.check.holder.FileHolderView;
import com.voxel.sense.infomsg.module.task.check.holder.ImageHolderView;
import com.voxel.sense.infomsg.module.task.check.holder.ReportHolderView;

/**
 * @author ChenYiYao
 * @date 2018/5/14
 * des :
 */
public class CheckTaskAdapter extends RecyclerAdapter<MultiItemBean<String>> {
    @Override
    protected int getItemViewType(int position, MultiItemBean<String> bean) {
        if (CheckTaskContract.TYPE_DESC == bean.getType()) {
            return R.layout.item_recycler_textview;
        } else if (CheckTaskContract.TYPE_FILE == bean.getType()) {
            return R.layout.item_recycler_task_file;
        } else if (CheckTaskContract.TYPE_REPORT == bean.getType()) {
            return R.layout.item_recycler_layout_report_list;
        }
        return R.layout.item_recycler_square_addpic;
    }

    @Override
    protected ViewHolder<MultiItemBean<String>> onCreateViewHolder(View root, int viewType) {
        ViewHolder holder;
        if (R.layout.item_recycler_textview == viewType) {
            holder = new DescHolderView(root);
        } else if (R.layout.item_recycler_task_file == viewType) {
            holder = new FileHolderView(root);
        } else if (R.layout.item_recycler_layout_report_list == viewType) {
            holder = new ReportHolderView(root);
        } else {
            holder = new ImageHolderView(root);
        }
        return holder;
    }
}
